<template>
  <div class="page-content">
    <div class="page-left">
      <dv-border-box-8 :color="[mainColorOpcity, mainColor]"><panel1 ref="panel1" @updateTime="handleUpdateTime" @timeChange="handleTimeChange"></panel1></dv-border-box-8>
    </div>
    <div class="page-right">
      <dv-border-box-8 :color="[mainColorOpcity, mainColor]"><panel2 ref="panel2" :time="time"></panel2></dv-border-box-8>
    </div>
  </div>
</template>

<script>
import panel1 from './components/panel1.vue'
import panel2 from './components/panel2.vue'

export default {
  name: 'index',
  components: { panel1, panel2 },
  props: {
    mainColorOpcity: String,
    mainColor: String,
  },
  data() {
    return {
      time: {},
    }
  },
  mounted() {
    window.onresize = () => {
      // 可视区域的高度
      const clientHeight = document.documentElement.clientHeight || document.body.clientHeight
      // screen是window的属性方法，window.screen可省略window，指的是窗口
      this.isFull = screen.height == clientHeight
      this.$refs.panel1.onResize()
      this.$refs.panel2.onResize()
    }
  },
  destroyed() {
    window.onresize = null
  },
  methods: {
    handleTimeChange(time) {
      this.time = time
    },
    handleUpdateTime(time) {
      this.$emit('updateTime', time)
    },
  },
}
</script>

<style scoped lang="scss">
$bgColor: #060a22;
$mainColor: #68cee0;
$mainColorOpcity: rgba(104, 206, 224, 0.3);

.page-content {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  .page-left {
    flex: 1 1 auto;
    width: 25vw;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
  }
  .page-right {
    flex: 1 1 auto;
    width: 75vw;
    height: 100%;
  }
}
</style>
